﻿
#include "Common/TableDataEx/TitleCfg.h"
#include "Common//TableData/TitleTitleCfg.h"

TitleCfg::TitleCfg()
{
	m_mapTitleParam.clear();
}

TitleCfg::~TitleCfg()
{

}

bool TitleCfg::Init()
{
	if (!ProcessArea())
	{
		return false;
	}

	return true;
}

void TitleCfg::UnInit()
{
	m_mapTitleParam.clear();
}

bool TitleCfg::ProcessArea()
{
	const TitleTitleCfgMap *pTitleMapCfg = g_GetTitleTitleCfgTable()->GetTitleTitleCfgMap();
	if (nullptr != pTitleMapCfg)
	{
		TitleTitleCfgMap::const_iterator iter = pTitleMapCfg->begin();
		for (; iter != pTitleMapCfg->end(); ++iter)
		{
			VEC_INT32 vParam;
			CommonApi::SplitStrToVecInt(iter->second.eventValue, ",", &vParam);
			m_mapTitleParam[iter->first] = vParam;
		}
	}
	return true;
}

VEC_INT32* TitleCfg::GetTitleParamByTitleID(uint32_t titleID)
{
	MAP_UINT32_VEC_INT32::iterator iter = m_mapTitleParam.find(titleID);
	if (iter==m_mapTitleParam.end())
	{
		return nullptr;
	}

	return &iter->second;
}